﻿using FinalYear.Helpers;
using System;
using System.ComponentModel;
using System.IO.Ports;

namespace FinalYear.iNavigate.Classes
{
    public class SerialManager
    {
        internal SerialPort currentPort;

        private IContainer components;

        public SerialManager()
        {
            this.components = new Container();
            this.currentPort = new SerialPort(components);
            this.currentPort.PortName = Constants.DEFAULTCOMPORT;
            this.currentPort.BaudRate = Constants.SONARBAUDRATE;
            this.currentPort.DtrEnable = true;
        }

        public bool CheckPort()
        {
            return this.currentPort.IsOpen;
        }

        public void OpenPort()
        {
            try
            {
                this.currentPort.Open();
            }
            catch (Exception ex)
            {
            }
        }
    }
}